<template>
    <div v-has-permi="['back']">
      <square-button :title="title" v-on="$listeners" v-bind="$attrs" icon="el-icon-back" @click="toBack()"></square-button>
      <suggestion-common-dialog  v-if="suggestionInfo.visible" :visible.sync="suggestionInfo.visible" v-model="suggestionInfo.msg" @callback="suggestionInfo.callback" :btn="btn"></suggestion-common-dialog>
    </div>
</template>
<script>
    import SquareButton from "@/components/WorkFlowsDialog/Case/SquareButton";
    import workManagement from "@/api/workManagement/index";
    import eventBus from "@/utils/eventBus";
    import SuggestionCommonDialog from '../SuggestionCommonDialog'
    export default {
        name: "BackButton",
        components: { SuggestionCommonDialog, SquareButton},
        props: {
            title: {
                type: String,
                default: "退回"
            },
            row:{
              type:Object,
              default: ()=>{}
            }
        },
        data() {
            return {
                visible:false,
                suggestionInfo:{visible:false,msg:"",callback:()=>{}},
                btn:{alert_text:"您确认将此审批单退回到上一处理人？"}
            }
        },
        computed: {},
        created() {
          console.log('----tuihui---')
        },
        methods: {
            showDialog() {
                this.visible=true
            },
            toBack() {
              this.suggestionInfo.visible = true;
              this.suggestionInfo.callback = ()=>{
                workManagement.setTicketsRefund(this.row.ticket,{"suggestion":this.suggestionInfo.msg}).then(res=>{
                  this.msgSuccess(res.msg)
                  eventBus.$emit("closeDetailDialog",true)
                })
              }
            },
        }
    }
</script>

